package com.ynny.chapter07three.service;

import com.ynny.chapter07three.dao.UserDao;
import com.ynny.chapter07three.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserDao userDao;


    @Override
    public int register(User user) {

        User repeatUser = userDao.selectUserByUserName(user.getNumber());
        if (repeatUser != null){

            return 404;
        }
        int i = userDao.insertUser(user);

        if (i != 1){
            return 500;
        }
        return 405;
    }

//    @Override
//    public int resigister(User user) {
//        return 0;
//    }
}